package com.fixme4trade.view;

import java.util.List;
import javax.inject.Inject;
import com.fixme4trade.business.ProductBC;
import com.fixme4trade.business.UserBC;
import com.fixme4trade.domain.Product;
import com.fixme4trade.template.PagedListPageBean;

import br.gov.frameworkdemoiselle.annotation.NextView;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;

@ViewController
@NextView("/auth/product_edit.xhtml")
@PreviousView("/auth/product_list.xhtml")
public class ProductListBySellerMB extends PagedListPageBean<Product, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private ProductBC bc;
	
	@Inject
	private UserBC userBC;

	@Override
	protected List<Product> handleResultList() {
		return this.bc.getProductsBySeller(userBC.getAuthenticatedSeller());		
	}
	
	@Override
	protected void handleDelete(Long id) {		
		bc.delete(id);		
	}
}